package com.cloudsigns.factorymanager2.project.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.project.bean.ProductBean;
import com.cloudsigns.factorymanager2.project.myinerface.ItemCheckedChangeListener;

import java.util.ArrayList;
import java.util.List;

public class PersonnelControlPermissionAdapter extends BaseAdapter{
    private Context context;
    private List<ProductBean> datas = new ArrayList<ProductBean>();
    private LayoutInflater inflater;
    private String tag = "";
    private List<String> selectedItemList = new ArrayList<String>();
    private ItemCheckedChangeListener itemCheckedChangeListener;

    public PersonnelControlPermissionAdapter(Context context, String tag) {
        this.context = context;
        this.inflater = LayoutInflater.from(context);
        this.tag = tag;
    }

    public void setData(List<ProductBean> list) {
        this.datas.clear();
        if (null != list) {
            this.datas.addAll(list);
        }

    }

    public void setItemCheckedChangeListener(ItemCheckedChangeListener itemCheckedChangeListener) {
        this.itemCheckedChangeListener = itemCheckedChangeListener;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public ProductBean getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        final ViewHolder holder;
        if (view == null) {
            holder = new ViewHolder();

            view = inflater.inflate(R.layout.item_personnel_control_permission, null);
            holder.tv_project_name = view.findViewById(R.id.tv_project_name);
            holder.tv_project_area = view.findViewById(R.id.tv_project_area);
            holder.img_remove = view.findViewById(R.id.img_remove);
            holder.img_edit = view.findViewById(R.id.img_edit);

            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        return view;
    }

    private class ViewHolder {
        private TextView tv_project_name;
        private TextView tv_project_area;
        private ImageView img_remove;
        private ImageView img_edit;
    }
}
